
/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2022原作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证和
 *许可证下的限制。
 */

package org.springframework.scheduling.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.aot.hint.annotation.Reflective;

/**
 * Annotation that marks a method as a candidate for <i>asynchronous</i> execution.
 *
 * <p>Can also be used at the type level, in which case all the type's methods are
 * considered as asynchronous. Note, however, that {@code @Async} is not supported
 * on methods declared within a
 * {@link org.springframework.context.annotation.Configuration @Configuration} class.
 *
 * <p>In terms of target method signatures, any parameter types are supported.
 * However, the return type is constrained to either {@code void} or
 * {@link java.util.concurrent.Future}. In the latter case, you may declare the
 * more specific {@link org.springframework.util.concurrent.ListenableFuture} or
 * {@link java.util.concurrent.CompletableFuture} types which allow for richer
 * interaction with the asynchronous task and for immediate composition with
 * further processing steps.
 *
 * <p>A {@code Future} handle returned from the proxy will be an actual asynchronous
 * {@code Future} that can be used to track the result of the asynchronous method
 * execution. However, since the target method needs to implement the same signature,
 * it will have to return a temporary {@code Future} handle that just passes a value
 * through: for example, Spring's {@link AsyncResult}, EJB 3.1's {@link jakarta.ejb.AsyncResult},
 * or {@link java.util.concurrent.CompletableFuture#completedFuture(Object)}.
 *
 * @author Juergen Hoeller
 * @author Chris Beams
 * @since 3.0
 * @see AnnotationAsyncExecutionInterceptor
 * @see AsyncAnnotationAdvisor
 */
/**
 *将方法标记为<i>异步</i>执行的候选方法的注释。
 *
 *＜p＞也可以在类型级别使用，在这种情况下，所有类型的方法都是
 *被认为是异步的。但是，请注意，不支持｛@code@Async｝
 *在中声明的方法
 *｛@link org.springframework.context.annation.Configuration@Configuration｝类。
 *
 *<p>在目标方法签名方面，支持任何参数类型。
 *但是，返回类型被约束为｛@code void｝或
 *｛@link java.util.concurrent.FFuture｝。在后一种情况下，您可以声明
 *更具体的{@linkorg.springframework.util.concurrent.ListnableFuture}或
 *｛@link java.util.concurrent.CompletableFuture｝类型，允许更丰富的
 *与异步任务的交互以及与
 *进一步的处理步骤。
 *
 *<p>从代理返回的｛@code Future｝句柄将是一个实际的异步句柄
 *｛@code Future｝，可用于跟踪异步方法的结果
 *执行。但是由于目标方法需要实现相同的签名，
 *它必须返回一个只传递值的临时{@codeFuture}句柄
 *通过：例如Spring的{@link-AncResult}、EJB 3.1的{@link jakarta.EJB.AncResult}，
 *或{@link java.util.concurrent.CompleteFuture#completedFuture（对象）}。
 *
 *@作者于尔根·霍勒
 *@作者Chris Beams
 *@自3.0起
 *@参见AnnotationSyncExecutionInterceptor
 *@请参阅AsyncAnnotationAddvisor
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Reflective
public @interface Async {

	/**
	 * A qualifier value for the specified asynchronous operation(s).
	 * <p>May be used to determine the target executor to be used when executing
	 * the asynchronous operation(s), matching the qualifier value (or the bean
	 * name) of a specific {@link java.util.concurrent.Executor Executor} or
	 * {@link org.springframework.core.task.TaskExecutor TaskExecutor}
	 * bean definition.
	 * <p>When specified in a class-level {@code @Async} annotation, indicates that the
	 * given executor should be used for all methods within the class. Method-level use
	 * of {@code Async#value} always overrides any qualifier value configured at
	 * the class level.
	 * <p>The qualifier value will be resolved dynamically if supplied as a SpEL
	 * expression (for example, {@code "#{environment['myExecutor']}"}) or a
	 * property placeholder (for example, {@code "${my.app.myExecutor}"}).
	 * @since 3.1.2
	 */
	/**
	 *指定异步操作的限定符值。
	 *<p>可用于确定执行时要使用的目标执行器
	 *异步操作，匹配限定符值（或bean
	 *name），或者
	 *｛@link org.springframework.core.task.TaskExecutior任务执行器任务执行器｝
	 *bean定义。
	 *＜p＞当在类级别｛@code@Async｝注释中指定时，表示
	 *给定的executor应该用于类中的所有方法。方法级使用
	 *｛@code Async#值｝的始终覆盖在配置的任何限定符值
	 *班级级别。
	 *<p>如果作为SpEL提供，则限定符值将动态解析
	 *表达式（例如，{@code“#{environment['myExecution']}”}）或
	 *属性占位符（例如，｛@code“$｛my.app.myExecutor｝”｝）。
	 *@自3.1.2起
	 */
	String value() default "";

}
